import Vue from 'vue'

// 初始化样式
import 'normalize.css/normalize.css' // A modern alternative to CSS resets

// 导入第三方组件库
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n
// 设置全局样式
import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

// 挂载i18n的插件
import i18n from '@/lang'

// 配置ElementUI的中英切换逻辑
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})

// 引入
import * as directive from '@/directive'

// 注册打印插件
import print from 'vue-print-nb'
Vue.use(print)

Object.keys(directive).forEach(item => {
  Vue.directive(item, directive[item])
})
// console.log(Object.keys(directive))

// 声明全局过滤器
import * as filters from '@/filters'
Object.keys(filters).forEach(k => { Vue.filter(k, filters[k]) })

// 导入svg精灵图
import '@/icons' // icon
// 导入权限认证
import '@/permission' // permission control

// // 全局注册组件
// import PageTools from '@/components/PageTools'
// Vue.component('PageTools', PageTools)

// 注册插件模块
import Components from './components'
Vue.use(Components)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */

// 这一行暂时用不到
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  i18n,
  router,
  store,
  render: h => h(App)
})
